var Tile = require('../DAO/schemaTile.js').Tile;
var Hero = require('../DAO/schemaHero.js').Hero;


function tileToDoc(tile){
    var tile_doc = new Tile();
    var row = (tile.x / 128);
    var col = (tile.y / 64);

    //tile_doc._id = tile._id;
    tile_doc.id = tile.id;
    tile_doc.position = { row: row, col: col };
    tile_doc.canPass = tile.canPass;
    tile_doc.humidity = tile.humidity;
    tile_doc.fertility = tile.fertility;
    tile_doc.fertilityCap = tile.fertilityCap;

    return tile_doc;
}

function heroToDoc(hero){
    var hero_doc = new Hero();
    var row = (hero.x / 128);
    var col = (hero.y / 64);

    hero_doc.id = hero.id;
    hero_doc.name = hero.name;
    hero_doc.gold = hero.gold;
    hero_doc.level = hero.level;
    hero_doc.position = { row: row, col: col };

    return hero_doc;
}


exports.tileToDoc = tileToDoc;
exports.heroToDoc = heroToDoc;